package com.rabbitmq.learn.pubsub;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.learn.common.ConnectionUtils;
import com.rabbitmq.learn.common.RabbitMqConstant;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * Created by Lxk on 2019/8/11.
 */
public class Sender {

    public static void main(String[] args) throws IOException, TimeoutException {
        Connection con = ConnectionUtils.getConnection();

        Channel channel = con.createChannel();

        channel.exchangeDeclare(RabbitMqConstant.PubSub.EXCHANGE_NAME,"fanout");

        String msg = "pub/sub msg";

        channel.basicPublish(RabbitMqConstant.PubSub.EXCHANGE_NAME,"",null,msg.getBytes());

        System.out.println("msg send success!!");

        channel.close();

        con.close();
    }

}
